home *** CD-ROM | disk | FTP | other *** search
- /*
- File: MyCaptureAppShell.c
-
- Contains: MyCaptureApp shell.
-
- Written by: John Wang
-
- Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <1> 04/04/94 JW Created.
-
- To Do:
- Wait till leave word rectangle
- little L processor that Kat doesn't think should really be neccessary
-
-
- */
-
-
- #include <Types.h>
- #include <Memory.h>
- #include <QuickDraw.h>
- #include <Palettes.h>
- #include <QDOffscreen.h>
- #include <Errors.h>
- #include <Fonts.h>
- #include <Dialogs.h>
- #include <Windows.h>
- #include <Menus.h>
- #include <Events.h>
- #include <Devices.h>
- #include <DiskInit.h>
- #include <OSUtils.h>
- #include <Resources.h>
- #include <ToolUtils.h>
- #include <AppleEvents.h>
- #include <EPPC.h>
- #include <Gestalt.h>
- #include <Processes.h>
- #include <Balloons.h>
- #include <Aliases.h>
- #include <MixedMode.h>
- #include <Scrap.h>
- #include <LowMem.h>
- #include <Timer.h>
- #include <Serial.h>
- #include <Speech.h>
- #include <TextUtils.h>
-
- #include <string.h>
-
- #include "CommandStrings.h"
-
-
-
- #include "MyUtils.h"
- #include "DVDRemote.h"
-
- #define kMouseRegionWidth 120
- #define kMouseRegionHeight 50
-
-
- #define rMonitor 1000
- #define kSendButton 1
- #define kStopButton 2
- #define kQuitButton 3
- #define kMsgBox 4
- #define kSendSpinner 5
- #define kRcvSpinner 7
- #define kHoldFlag 9
- #define kBreakButton 10
-
- #define rSerDataRsrc 128
- #define rSpinnerIcon 1000
- #define rHeldIcon 128
- #define rNotHeldIcon 129
-
- #define rPortOpenALRT 256
- #define kReset 2
-
- #define kCtlEnable 0
- #define kCtlDisable 255
- #define kSerBufSize 16384
- #define kSerRdSize 64
- #define kSerConfig baud9600 + noParity + data8 + stop10
- #define kBreakLength 666 // serial break length in milliseconds
-
- #define drvrName 0x12 // offset to driver name in 'DRVR' std. header
-
- #define dOpened 5
- #define dRAMBased 6
- #define drvrActive 7 // Device Manager DCtlFlag bits
-
- #define kSerStatus 8
- #define kSerClrBrk 11 // Serial Driver csCodes
- #define kSerSetBrk 12
- #define kSerHShakeDTR 14
- #define breakR0 128 // mask for break bit in SCC RR0 -- See TN #56
- #define breakErr 8 // mask for break bit in cumErrs -- System 7.0
-
- //#define kInputDriver "\p.AIn"
- //#define kOutputDriver "\p.AOut"
- #define kInputDriver "\p.IrIn"
- #define kOutputDriver "\p.IrOut"
-
-
- #define kDVDPlayerSignature 'ombz'
- #define kCDPlayerSignature 'aucd'
- //#define kTargetAppSignature kDVDPlayerSignature
- #define kTargetAppSignature kCDPlayerSignature
-
-
- //#define kDVDName "\pApple DVD Player"
- //#define kCDName "\pAppleCD Audio Player"
-
- #define kUpArrowKey 0x7E1E
- #define kLeftArrowKey 0x7B1C
- #define kDownArrowKey 0x7D1F
- #define kRightArrowKey 0x7C1D
-
- #define kSpaceBarKey 0x3120
- #define kPeriodKey 0x2F2E
- #define kEscapeKey 0x351B
- #define kEKey 0x0E45
- #define kMKey 0x2E4D
- #define k0Key 0x1D30
- #define k1Key 0x1231
- #define k2Key 0x1332
- #define k3Key 0x1433
- #define kPKey 0x2350
-
- #ifdef powerc
- //QDGlobals qd;
- #endif
-
- Boolean gDone; // Set to true if you want to Application to kindly quit.
-
- WindowPtr gWin = 0;
-
- GWorldPtr gRecognizeThis = 0;
- unsigned long gLastTicks = 0;
-
-
- Ptr gpSerBuf, *ghSerBuf, // serial receive buffer
- gpOutputData, *ghOutputData, // send buffer
- gpBitBucket, *ghBitBucket; // receive processing buffer
-
- long gOutputDataSize;
- IOParam *gpSendPB, **ghSendPB; // for PBWrite calls to send data
- short gSysVersion,
- gOutRefNum, gInRefNum,
- // gSendCount = 0,
- gBitBucketCount = 0;
- //char *panicString = "Help! I'm stuffed! And here's a bunch of characters to prove it!\n\r";
- //TMTask gPostEventTask;
-
- ProcessSerialNumber gTargetPSN;
-
- long gMessageToPost = 0;
- short gMessageModifiers = 0;
-
-
- void Initialize (void);
- short SerInitialize (void);
- void CleanUp (void);
- Boolean OpenSERD (void);
- void CloseSERD (void);
- //void DoIOStuff (void);
- OSErr SendData (void);
- void CheckSerData (void);
- //void CheckSerStatus (void);
- //pascal Boolean NullGrabber (DialogPtr, EventRecord *evt, short *itemHit);
- //pascal void SendCompRout (void);
- //pascal void FlagBreakTimeout (void);
- void ProcessBitBucket(void);
- //void PrimeTMTask(void);
- void ProcessString(char* s);
- void FindTargetPSN(void);
- void SendEvents(void);
-
- //#pragma parameter PostEventProc(__A0)
- //pascal void PostEventProc (void);
-
-
- //void DoStuffo(void);
-
- /* ------------------------------------------------------------------------- */
-
- void main()
- {
- EventRecord myEvent;
- long yieldTime = 10;
- WindowPtr foundWindow;
- short windowPart;
- Boolean isEvent;
- GrafPtr savePort;
- GDHandle saveGD;
- OSErr err=noErr;
-
- // Initialize here. Set the yield time too.
- // bestTimeBase
- // err = ProfilerInit(collectDetailed,microsecondsTimeBase,50,10);
- Initialize();
- FindTargetPSN();
-
- if(SerInitialize() != noErr) DebugStr("\pCan't init serial stuff");
-
- // open the Serial Driver
- if (! OpenSERD()) DebugStr("\pCan't open serial drvr");
-
-
- // Event loop.
- for ( ; ; ) {
-
- // Get the event.
- isEvent = WaitNextEvent(everyEvent, &myEvent, yieldTime, nil);
-
- if(myEvent.what == keyDown)
- {
- myEvent.what = keyDown;
- }
-
- CheckSerData();
- ProcessBitBucket();
-
- SendEvents();
-
- // If the event is unhandled by app specific event handling, then we proceed.
- if ( isEvent ) {
- switch ( myEvent.what ) {
-
- case mouseDown:
- // Get current port and device.
- GetPort(&savePort);
- saveGD = GetGDevice();
-
- // Set the port and gdevice to the window if we own the window.
- // We can then assume anytime the event occured in one of our windows,
- // that the port and gdevice are set correctly.
- windowPart = FindWindow(myEvent.where, &foundWindow);
- SetPort(foundWindow);
- SetGDevice(GetMainDevice());
-
- // Handle the different mouse down events.
- switch ( windowPart ) {
- case inSysWindow:
- SystemClick(&myEvent, foundWindow);
- break;
- case inMenuBar:
- DoCommand(MenuSelect(myEvent.where));
- break;
- case inContent:
- break;
- case inDrag:
- // If dragging one of the application's windows, then handle it.
- // However, if we are dragging a zoomed window, we
- // must remember to save the new window location into the
- // zoomed rect in the data handle. Otherwise, the event
- // manager will think that we are no longer zoomed.
- {
- WStateData *zoomData;
- Rect windowRect;
-
- // Get window location before drag.
- GetGlobalWindow(foundWindow, &windowRect);
-
- // Drag window.
- DragWindow (foundWindow, myEvent.where, &qd.screenBits.bounds);
- // MyDrag(foundWindow, myEvent.where);
-
- // If the windowRect in global coordinates matches the zoom rect,
- // then assume that we are dragging the zoomed window. update
- // zoom rect.
- zoomData = (WStateData *) *(((CWindowPeek) foundWindow)->dataHandle);
- if ( EqualRect(&(zoomData->stdState), &windowRect) ) {
- GetGlobalWindow(foundWindow, &windowRect);
- zoomData = (WStateData *) *(((CWindowPeek) foundWindow)->dataHandle);
- zoomData->stdState = windowRect;
- }
- }
- break;
- case inGrow:
- break;
- case inGoAway:
- // Handle clicking on the go away. If it is the clip window,
- // then hide it.
- if ( TrackGoAway (foundWindow, myEvent.where) ) {
- BringToFront(foundWindow);
- // MyClose();
- DisposeWindow(foundWindow);
- if(foundWindow == gWin) gWin = 0;
- }
- break;
- case inZoomIn:
- case inZoomOut:
- break;
- default:
- break;
- }
-
- // Restore port and device.
- SetPort(savePort);
- SetGDevice(saveGD);
-
- break;
- case keyDown:
- case autoKey:
- if ( myEvent.modifiers & cmdKey ) {
- if ( myEvent.what == keyDown ) {
- DoCommand(MenuKey(myEvent.message & charCodeMask));
- }
- }
- break;
- case updateEvt:
- // Handle update events for window and clip window.
- foundWindow = (WindowPtr) myEvent.message;
- GetPort(&savePort);
- saveGD = GetGDevice();
- SetPort(foundWindow);
- SetGDevice(GetMainDevice());
- BeginUpdate(foundWindow);
- EndUpdate(foundWindow);
- SetPort(savePort);
- SetGDevice(saveGD);
- break;
- case diskEvt:
- // This handles a bad disk. Otherwise the disk will not eject.
- if ( myEvent.message >> 16 ) {
- Point tempPoint;
- tempPoint.v = 50; tempPoint.h = 50;
- DIBadMount(tempPoint, myEvent.message);
- }
- break;
- case activateEvt:
- break;
- case app4Evt:
- switch ( myEvent.message >> 24 ) {
- case suspendResumeMessage:
- // yieldTime = MyYieldTime(myEvent.message & 0x01);
- break;
- default:
- DebugStr("\pUnexpected suspend/resume message.");
- }
- break;
- default:
- break;
- }
- }
-
- // If DoneFlag set, then quit.
- if ( gDone ) {
- // err = ProfilerDump((unsigned char *)"\pProfileInfo");
- // ProfilerTerm();
- CloseSERD(); // close the Serial Driver
- CleanUp();
-
- ExitToShell();
- }
- }
- }
-
- /* ------------------------------------------------------------------------- */
-
- void Initialize()
- {
- // OSErr err;
- Handle myMenu;
- // Rect bounds;
-
- // Initialize Managaer.
- MaxApplZone();
- MoreMasters(); MoreMasters();
- MoreMasters(); MoreMasters();
- MoreMasters(); MoreMasters();
- MoreMasters(); MoreMasters();
- InitGraf(&qd.thePort);
- InitFonts();
- FlushEvents(everyEvent, 0);
- InitWindows();
- InitDialogs(nil);
- InitCursor();
-
- // Set up menus.
- myMenu = GetNewMBar(kMENUBAR);
- SetMenuBar(myMenu);
- DisposeHandle(myMenu);
- AppendResMenu(GetMenuHandle(kMENU_APPLEID), 'DRVR');
- DrawMenuBar();
-
- // Setup other globals.
- gDone = false;
-
- /* // Create window:
- bounds.top = 50;
- bounds.left = 50;
- bounds.bottom = bounds.top + kMouseRegionHeight;
- bounds.right = bounds.left + kMouseRegionWidth;
-
- gWin = NewCWindow(0, &bounds, "\pBits", true, documentProc, (WindowPtr)-1, true, 0);
- SetPort(gWin);
-
- // Create gworld:
- bounds.top = bounds.left = 0;
- bounds.right = kMouseRegionWidth;
- bounds.bottom = kMouseRegionHeight;
-
- err = NewGWorld(&gRecognizeThis, 16, &bounds, nil, nil, 0);
- */
- return;
- }
-
- short SerInitialize (void)
- {
- long result;
- OSErr gestErr;
-
- gestErr = Gestalt(gestaltSystemVersion, &result);
- gSysVersion = result;
-
- ghSendPB = (IOParam **) NewHandle( sizeof(IOParam));
- if (ghSendPB != NULL) {
- MoveHHi((Handle) ghSendPB);
- HLock((Handle) ghSendPB);
- gpSendPB = *ghSendPB;
- }
- else {
- return MemError();
- }
-
- ghSerBuf = NewHandle(kSerBufSize);
- if (ghSerBuf != NULL) {
- MoveHHi((Handle) ghSerBuf);
- HLock((Handle) ghSerBuf);
- gpSerBuf = *ghSerBuf;
- }
- else {
- DisposeHandle((Handle) ghSendPB);
- return MemError();
- }
-
- ghBitBucket = NewHandle(kSerBufSize+1);
- if (ghBitBucket != NULL) {
- MoveHHi(ghBitBucket);
- HLock(ghBitBucket);
- gpBitBucket = *ghBitBucket;
- }
- else {
- DisposeHandle((Handle) ghSendPB);
- DisposeHandle((Handle) ghSerBuf);
- return MemError();
- }
-
- ghOutputData = Get1Resource('sDAT', rSerDataRsrc);
- if (ghOutputData != NULL) {
- MoveHHi(ghOutputData);
- HLock(ghOutputData);
- gpOutputData = *ghOutputData;
- gOutputDataSize = GetResourceSizeOnDisk(ghOutputData);
- }
- else {
- DisposeHandle((Handle) ghSendPB);
- DisposeHandle((Handle) ghSerBuf);
- DisposeHandle(ghBitBucket);
- return ResError();
- }
-
- return noErr;
- }
-
-
- void CleanUp (void)
- {
-
- DisposeHandle((Handle) ghSendPB);
- DisposeHandle(ghSerBuf);
- DisposeHandle(ghBitBucket);
- }
-
-
-
- void DoCommand(long mResult)
- {
- short theMenu, theItem;
- Str255 myStr;
- GrafPtr savePort;
- GDHandle saveGD;
-
- theItem = LoWord(mResult);
- theMenu = HiWord(mResult);
-
- if ( theItem != 0 || theMenu != 0 ) {
- switch ( theMenu ) {
- case kMENU_APPLEID:
- if ( theItem == 1 ) {
- Alert(kALERT_ABOUT, nil);
- } else {
- GetMenuItemText(GetMenuHandle(kMENU_APPLEID), theItem, myStr);
- GetPort(&savePort);
- saveGD = GetGDevice();
- (void) OpenDeskAcc(myStr);
- SetPort(savePort);
- SetGDevice(saveGD);
- }
- break;
-
- case kMENU_FILEID:
- switch ( theItem ) {
- case kMENU_FILENEW:
- // MyNew();
- break;
- case kMENU_FILECLOSE:
- // MyClose();
- break;
- case kMENU_FILEQUIT:
- gDone = true;
- break;
- default:
- ReportFatal("\pError in handling file menu:", theItem);
- }
- break;
-
- default:
- ReportFatal("\pError in handling menu:", theMenu);
- }
- }
- HiliteMenu(0);
- }
-
-
-
-
- Boolean OpenSERD (void)
- {
- OSErr openOutErr, openInErr;
- OSErr setBufErr, setCfgErr, setHskErr;
- SerShk hskFlags;
- // long finalTicks;
- Boolean takeOverPort = true;
- // Boolean openAOut, openAIn;
-
- /* openAOut = AssertDrvrOpen(kOutputDriver, &gOutRefNum) == noErr;
- openAIn = AssertDrvrOpen(kInputDriver, &gInRefNum) == noErr;
- if (openAOut || openAIn) {
- if (takeOverPort = CautionAlert(rPortOpenALRT, nil) == kReset) {
- if (openAIn) {
- KillIO(gInRefNum);
- CloseDriver(gInRefNum);
- }
- if (openAOut) {
- KillIO(gOutRefNum);
- CloseDriver(gOutRefNum);
- }
- }
- }
-
- if (takeOverPort) {
- */
- openOutErr = OpenDriver(kOutputDriver, &gOutRefNum);
- openInErr = OpenDriver(kInputDriver, &gInRefNum);
-
- if (openOutErr == noErr && openInErr == noErr) {
-
- // It's always good to first set a non-default input buffer, if desired.
- // There is no output buffering, so specify only the input driver.
-
- setBufErr = SerSetBuf(gInRefNum, gpSerBuf, kSerBufSize);
-
- hskFlags.fXOn = false;
- hskFlags.fCTS = true;
- hskFlags.xOn = 0x11;
- hskFlags.xOff = 0x13;
- hskFlags.errs = 0;
-
- if (gSysVersion >= 0x0700) {
- hskFlags.evts = 0; // I can use new means of break detection.
- }
- else {
- hskFlags.evts = breakEvent; // I need the driver to post break events.
- }
-
- hskFlags.fInX = false;
- hskFlags.fDTR = true;
-
- // SerHShake() does not support full DTR/CTS hardware handshaking. You
- // accomplish the same thing and more with a Control call and csCode 14.
- // You only need to specify hskFlags once, to the output driver.
-
- setHskErr = Control(gOutRefNum, kSerHShakeDTR, (Ptr) &hskFlags);
-
- // Now reset both input and output drivers with the same configuration.
- // Only a single call to the output driver is necessary to do this.
- // Differing concurrent input/output baud rates are not supported.
-
- setCfgErr = SerReset(gOutRefNum, kSerConfig);
-
- }
- else DebugStr("\pCan't open driver");
- // }
-
- return takeOverPort;
- }
-
-
-
- void CloseSERD (void)
- {
- OSErr killErr, closeOutErr, closeInErr;
-
- killErr = KillIO(gInRefNum);
- closeInErr = CloseDriver(gInRefNum);
-
- killErr = KillIO(gOutRefNum);
- closeOutErr = CloseDriver(gOutRefNum);
-
- }
-
-
-
-
- void CheckSerData (void)
- {
- OSErr checkBufErr, serRdErr;
- long charCount;
-
- checkBufErr = SerGetBuf(gInRefNum, &charCount);
- if (checkBufErr == noErr) {
-
- // The general strategy here is this: if number of available characters
- // meets a certain minimum threshold, then I read in everything in the
- // buffer. If I get delayed, I'll catch up quickly.
-
- // if (charCount != 0 && charCount >= reqBytes) {
- if (charCount > 0) {
-
- serRdErr = FSRead(gInRefNum, &charCount, &gpBitBucket[gBitBucketCount]);
- if (serRdErr == noErr) {
- gBitBucketCount += charCount;
- gpBitBucket[gBitBucketCount] = 0xFF; // append an 'unfinished string' terminator
- }
- }
- }
- }
-
- OSErr SendData (void)
- {
- gpSendPB->ioCompletion = 0;//(ProcPtr)0;// SendCompRout;
- gpSendPB->ioRefNum = gOutRefNum;
- gpSendPB->ioBuffer = gpOutputData;
- gpSendPB->ioReqCount = gOutputDataSize;
-
- // return PBWriteAsync((ParmBlkPtr) gpSendPB); // asynchronous self-sustaining sends
- return PBWriteSync((ParmBlkPtr) gpSendPB); // asynchronous self-sustaining sends
-
- }
-
- /*
- Searches the receive buffer, looking for
- completed (\r terminated) command strings to execute.
- */
- void ProcessBitBucket(void)
- {
- char* s = gpBitBucket;
- short i = 0;
- Boolean foundString = false;
-
- while(foundString == false && i < gBitBucketCount)
- {
- if(s[i] == '\r')
- {
- foundString = true;
- s[i] = 0; // null terminate the string
- }
- if(s[i] == 0xFF)
- {
- foundString = false;
- break;
- }
-
- i++;
- }
-
- if(foundString == true)
- {
- c2pstr(s);
- SpeakString((unsigned char*)s);
- p2cstr((unsigned char*)s);
-
- ProcessString(s);
-
- gBitBucketCount -= i;
- BlockMove(&s[i], &s[0], gBitBucketCount);
- }
-
- return;
- }
-
-
- /*
- Given a command string, set the right
- event up to be posted to the CD/DVD player
- */
- void ProcessString(char* s)
- {
-
- if(strcmp(s, kPlayCmd) == 0 ||
- strcmp(s, kPauseCmd) == 0)
- {
- // PostEvent(keyDown, ' ');
- gMessageToPost = kSpaceBarKey; // ' '
- gMessageModifiers = 0;
- }
- else if(strcmp(s, kStopCmd) == 0)
- {
- gMessageToPost = kPeriodKey; // cmd-.
- gMessageModifiers = cmdKey;
- }
- else if(strcmp(s, kFastFwdCmd) == 0)
- {
- gMessageToPost = kRightArrowKey; // cmd ->
- gMessageModifiers = cmdKey;
- }
- else if(strcmp(s, kRewindCmd) == 0)
- {
- gMessageToPost = kLeftArrowKey; // cmd <-
- gMessageModifiers = cmdKey;
- }
- else if(strcmp(s, kNextCmd) == 0)
- {
- gMessageToPost = kRightArrowKey; // -> arrow key
- gMessageModifiers = 0;
- }
- else if(strcmp(s, kPrevCmd) == 0)
- {
- gMessageToPost = kLeftArrowKey; // <- arrow key
- gMessageModifiers = 0;
- }
- else if(strcmp(s, kEjectCmd) == 0)
- {
- gMessageToPost = kEKey; // cmd-E
- gMessageModifiers = cmdKey;
- }
- else if(strcmp(s, kVolUpCmd) == 0)
- {
- gMessageToPost = kUpArrowKey; // cmd-up
- gMessageModifiers = cmdKey;
- }
- else if(strcmp(s, kVolDownCmd) == 0)
- {
- gMessageToPost = kDownArrowKey; // cmd-down
- gMessageModifiers = cmdKey;
- }
- else if(strcmp(s, kMuteCmd) == 0)
- {
- gMessageToPost = kMKey; // cmd-M
- gMessageModifiers = cmdKey;
- }
- else if(strcmp(s, kDVDMenuCmd) == 0)
- {
- gMessageToPost = kEscapeKey; // escape
- gMessageModifiers = 0;
- }
- else if(strcmp(s, kSizeTinyCmd) == 0)
- {
- gMessageToPost = k0Key; // cmd-0
- gMessageModifiers = cmdKey;
- }
- else if(strcmp(s, kSizeHalfCmd) == 0)
- {
- gMessageToPost = k1Key; // cmd-1
- gMessageModifiers = cmdKey;
- }
- else if(strcmp(s, kSizeNormCmd) == 0)
- {
- gMessageToPost = k2Key; // cmd-2
- gMessageModifiers = cmdKey;
- }
- else if(strcmp(s, kSizeFullCmd) == 0)
- {
- gMessageToPost = k3Key; // cmd-3
- gMessageModifiers = cmdKey;
- }
- else if(strcmp(s, kPresentCmd) == 0)
- {
- gMessageToPost = kPKey; // cmd-option-P
- gMessageModifiers = cmdKey | optionKey;
- }
-
- return;
- }
-
- /*
- Called repeatedly from our event loop,
- tries to send out an event if there is one pending.
- */
- void SendEvents(void)
- {
- OSErr theErr;
- ProcessSerialNumber frontProcNum;
- EvQElPtr theEventQElP;
- Boolean result=false;
-
- if (gMessageToPost)
- {
- theErr = GetFrontProcess(&frontProcNum);
-
- if (theErr == noErr)
- {
- theErr = SameProcess(&frontProcNum, &gTargetPSN, &result);
- if (theErr == noErr)
- {
- if (result == true)
- {
- theErr = PPostEvent(keyDown, gMessageToPost /*q == 0x0C71*/, &theEventQElP);
- theEventQElP->evtQModifiers = gMessageModifiers;
- gMessageToPost = 0;
- gMessageModifiers = 0;
- } else
- {
- SetFrontProcess(&gTargetPSN);
- }
- }
- }
- }
-
- return;
- }
-
- /************************************************************
- * Find PSN of target application
- *************************************************************/
- void FindTargetPSN(void)
- {
- OSErr theErr;
- ProcessSerialNumber thePSN;
- ProcessInfoRec theProcInfo;
- unsigned char theProcessName[32];
-
- thePSN.highLongOfPSN = 0;
- thePSN.lowLongOfPSN = kNoProcess;
-
- theProcInfo.processInfoLength = sizeof(theProcInfo);
- theProcInfo.processName = &theProcessName[0];
- theProcInfo.processAppSpec = nil;
-
- do
- {
- theErr = GetNextProcess(&thePSN);
- if (theErr == noErr)
- {
- theErr = GetProcessInformation(&thePSN, &theProcInfo);
- if (theErr == noErr)
- {
- // if ( EqualString(theProcInfo.processName, "\pTimeMgrTest", false, false) )
- if (theProcInfo.processType == 'APPL' && theProcInfo.processSignature == kTargetAppSignature)
- {
- gTargetPSN = thePSN;
- break;
- }
- }
- }
- } while (theErr != procNotFound);
-
- if (theErr == procNotFound) {
- DebugStr("\pCouldn't find target app");
- }
- return;
- }
-
- /************************************************************
- * Initialize MyTimeMgrTask
- *************************************************************/
- /*void InitMyTimeMgrTask(void)
- {
- // Should call Gestalt to make sure the extended TimeMgr is present...
-
- gMyTimerUPP = NewTimerProc(MyTimeMgrTask);
-
- // Set up the fields in gMyTMTask
- gMyTMTask.tmAddr = gMyTimerUPP; // init as per IM
- gMyTMTask.tmWakeUp = 0; // init as per IM
- gMyTMTask.tmReserved = 0; // init as per IM
-
- // Install MyTimeMgrTask into the queue
- InsXTime((QElemPtr) &gMyTMTask);
-
- // Prime the task
- PrimeTime((QElemPtr) &gMyTMTask, kDelay);
-
- return;
- }
- */
-
-
- /************************************************************
- * MyTimeMgrTask
- *************************************************************/
- /*void MyTimeMgrTask(TMTaskPtr tmTaskPtr)
- {
- OSErr theErr;
- ProcessSerialNumber frontProcNum;
- EvQElPtr theEventQElP;
- Boolean result=false;
-
- if (gMessageToPost)
- {
- theErr = GetFrontProcess(&frontProcNum);
- // theErr = GetCurrentProcess(&frontProcNum);
- if (theErr == noErr)
- {
- theErr = SameProcess(&frontProcNum, &gTargetPSN, &result);
- if (theErr == noErr)
- {
- if (result == true)
- {
- theErr = PPostEvent(keyDown, gMessageToPost, &theEventQElP);
- theEventQElP->evtQModifiers = gMessageModifiers;
- gMessageToPost = 0;
- } else
- {
- SetFrontProcess(&gTargetPSN);
- }
- }
- }
- }
-
- // if (PostQuit != true)
- PrimeTime((QElemPtr) tmTaskPtr, kDelay);
-
- return;
- }
- */
-